// 快慢指针

var isPalindrome = function(head) {
    if(head == null || head.next == null) {return true}
    let slow = head
    let fast = head
    let temp1 = null ,temp2 = null
    while(fast !=null && fast.next !=null){
        temp1 = slow
        slow = slow.next
        fast = fast.next.next

        temp1.next  = temp2
        temp2 = temp1
    }
    if(fast){
        slow = slow.next
    }

    while(slow){
        if(slow.val != temp2.val){return false}
        slow = slow.next 
        temp2 = temp2.next
    }
    return true


};



// 作者：zz1998
// 链接：https://leetcode.cn/problems/palindrome-linked-list/solution/dai-ma-jian-ji-yi-chong-huan-bu-cuo-de-j-cacx/
// 来源：力扣（LeetCode）
// 著作权归作者所有。商业转载请联系作者获得授权，非商业转载请注明出处。